package com.changgou.search.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.search.service.ESManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manager")
public class ESManagerController {

    @Autowired
    private ESManagerService esManagerService;

    /**
     * @Description:    创建索引库结构
     * @Author:        wangqingsong
     * @param:           []
     * @return:          void
     * @CreateDate:     2020/11/27 14:41
     */
    @GetMapping("/create")
    public Result createMappingAndIndex() {
        esManagerService.createMappingAndIndex();
        return new Result(true, StatusCode.OK, "创建成功");
    }


    /**
     * @Description:    导入全部数据进入es
     * @Author:        wangqingsong
     * @param:           []
     * @return:          void
     * @CreateDate:     2020/11/27 15:15
     */
    @GetMapping("/import")
    public Result importAll() {
        esManagerService.importAll();
        return new Result(true, StatusCode.OK, "导入成功");
    }


}
